package cn.iocoder.yudao.module.wms.service.rdrecord10.listener;

import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEvent;
import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEventListener;
import cn.iocoder.yudao.module.wms.controller.admin.rdrecord01.vo.Rdrecord01SaveReqVO;
import cn.iocoder.yudao.module.wms.controller.admin.rdrecord10.vo.Rdrecord10SaveReqVO;
import cn.iocoder.yudao.module.wms.dal.dataobject.rdrecord01.Rdrecord01DO;
import cn.iocoder.yudao.module.wms.dal.dataobject.rdrecord01.Rdrecords01DO;
import cn.iocoder.yudao.module.wms.dal.dataobject.rdrecord10.Rdrecord10DO;
import cn.iocoder.yudao.module.wms.dal.dataobject.rdrecord10.Rdrecords10DO;
import cn.iocoder.yudao.module.wms.enums.BpmnVariableConstants;
import cn.iocoder.yudao.module.wms.service.rdrecord01.Rdrecord01Service;
import cn.iocoder.yudao.module.wms.service.rdrecord01.Rdrecord01ServiceImpl;
import cn.iocoder.yudao.module.wms.service.rdrecord10.Rdrecord10Service;
import cn.iocoder.yudao.module.wms.service.rdrecord10.Rdrecord10ServiceImpl;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.JavaDelegate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 生产入库监听器
 *
 * @author 芋道源码
 */
@Component
public class Rdrecord10Listener extends BpmProcessInstanceStatusEventListener implements JavaDelegate {
    private static final Logger logger = LoggerFactory.getLogger(Rdrecord10Listener.class);
    @Resource
    private Rdrecord10Service rdrecord10Service;

    @Override
    protected String getProcessDefinitionKey() {
        return Rdrecord10ServiceImpl.PROCESS_KEY;
    }

    @Override
    protected void onEvent(BpmProcessInstanceStatusEvent event) {
        rdrecord10Service.updateRdrecord10Status(new Rdrecord10SaveReqVO().setProcessInstanceId(event.getId()).setStatus(event.getStatus()));

    }

    @Override
    public void execute(DelegateExecution execution) {
        try {
            String reason = (String) execution.getVariable(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_REASON);
        } catch (Exception e) {
            logger.error("Error in PomainStatusListener", e);
        }
    }
}
